package org.example.springboot.dao;

import org.apache.ibatis.annotations.*;
import org.example.springboot.model.InBound;
import org.example.springboot.model.OutBound;

import java.time.LocalDateTime;
import java.util.List;
@Mapper
public interface OutBoundMapper {

    @Insert("insert into outbound(product_name, model_number, supplier_name,quantity,totalAmount,out_time,out_order_id) values (#{productName},#{modelNumber}, #{supplierName},#{quantity},#{totalAmount},#{outTime},#{outOrderId})")
    int insertOutBound(@Param("productName") String productName, @Param("modelNumber") String modelNumber,@Param("supplierName") String supplierName,@Param("quantity") String quantity,@Param("totalAmount") String totalAmount,@Param("outTime") String outTime,@Param("outOrderId") String outOrderId);

    @Select("select * from outbound")
    List<OutBound> getAllOutBound();

    @Select("select * from outbound where id = #{id}")
    OutBound getOutBoundById(@Param("id")int id);

    @Select("select * from outbound " + "where product_name like CONCAT('%', #{keyword}, '%') " + "or model_number like CONCAT('%', #{keyword}, '%')"+ "or supplier_name like CONCAT('%', #{keyword}, '%')"+ "or out_order_id like CONCAT('%', #{keyword}, '%')")
    List<OutBound> findOutBoundByKeyword(@Param("keyword")String keyword);

    @Delete("delete from outbound where id = #{id}")
    void deleteOutBoundById(@Param("id")int id);
}
